import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui';
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/adminlte.css'
import './assets/js/adminlte.js'
import './assets/global.css'
import axios from 'axios'
import VueRouter from 'vue-router'
import router from './router'
import store from './store'
axios.defaults.withCredentials=true
axios.defaults.baseURL='/api'

// 跨域请求拦截器
axios.interceptors.request.use(
    config => {
      // 从sessionStorage中获取JWT令牌
      const token = sessionStorage.getItem('token');
      // 将JWT令牌添加到请求头中
      if (token) {
        config.headers.token = `${token}`;
      }
      return config;
    },
    error => {
      return Promise.reject(error);
    }
);
// 响应拦截器
axios.interceptors.response.use(
    response => {
      return response;
    },
    error => {
      return Promise.reject(error);
    }
);
Vue.prototype.$axios =axios

Vue.config.productionTip = false
Vue.use(ElementUI,{size:'smal'})
Vue.use(ElementUI);
Vue.use(VueRouter);
new Vue({
  router,store,
  render: h => h(App),
}).$mount('#app')

